﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp_4._8
{
    public partial class DetailForm : Form
    {
        public DetailForm()
        {
            InitializeComponent();
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            (this.Owner as Form1).setSize(trackBar1.Value);
        }

        private void groupBox1_DockChanged(object sender, EventArgs e)
        {
            foreach (var ctrl in groupBox1.Controls) {

                if (ctrl is RadioButton && (ctrl as RadioButton).Checked) {

                  
                    (this.Owner as Form1).setFont((ctrl as RadioButton).Text);
                    break;
                }
            }
            
        }

        private void DetailForm_Load(object sender, EventArgs e)
        {
            string fontName = (this.Owner as Form).Font.ToString().Trim();

            foreach (var ctrl in groupBox1.Controls)
            {

                if (ctrl is RadioButton && string.Equals(fontName, (ctrl as RadioButton).Text)) {

                    (ctrl as RadioButton).Checked = true;
                }
               
            }
        }

        private void changeWallPaper_Click(object sender, EventArgs e)
        {
            if(openFileDialog1.ShowDialog() == DialogResult.OK){

                this.Owner.BackgroundImage = Image.FromFile(openFileDialog1.FileName);
            }
        }

        int i = 0;

        private void timer1_Tick(object sender, EventArgs e)
        {
            i = (i + 1) % imageList1.Images.Count;
            pictureBox1.Image =  imageList1.Images[i];
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
    }
}
